10 / 10

What is docker ps -a in Docker?

docker ps -a (or docker ps --all) lists ALL containers on the system — both running and stopped. Without the -a flag, docker ps only shows currently running containers. It is one of the most frequently used Docker commands for inspecting container state, finding container IDs, and debugging.

Basic Usage
Understanding the Output
All Possible STATUS Values
  1. 1

    Up X hours/minutes — container is currently running

  2. 2

    Exited (0) — container stopped successfully (exit code 0 = success)

  3. 3

    Exited (1) — container stopped with error (non-zero = failure)

  4. 4

    Exited (137) — container was killed (SIGKILL — often OOM or docker kill)

  5. 5

    Created — container created but never started

  6. 6

    Paused — container is paused (docker pause was called)

  7. 7

    Restarting — container is in restart loop

  8. 8

    Removing — container is being removed

  9. 9

    Dead — container is in a broken state, needs force removal

Useful Flags with docker ps
Filtering with --filter (-f)
Custom Formatting with --format
Practical Combinations with docker ps -a
docker ps -a vs docker container ls -a
docker ps vs docker ps -a
  1. 1

    docker ps — shows ONLY running containers (STATUS: Up)

  2. 2

    docker ps -a — shows ALL containers regardless of state

  3. 3

    docker ps -q — shows only IDs of running containers

  4. 4

    docker ps -aq — shows only IDs of ALL containers

  5. 5

    docker ps -l — shows the most recently created container

  6. 6

    docker ps -n 5 — shows last 5 created containers

  7. 7

    docker ps -as — shows running containers with disk size info

Key Takeaways
  1. 1

    docker ps shows only running containers — always use -a to see everything

  2. 2

    The STATUS column is the most important — it tells you exactly why a container stopped

  3. 3

    Exit code 0 = clean stop, non-zero = error — use docker logs to investigate

  4. 4

    Use -q flag to get just IDs — essential for scripting bulk operations

  5. 5

    Use --filter to narrow down containers by status, name, image, or label

  6. 6

    Use --format for clean readable output or JSON for programmatic processing

  7. 7

    docker ps -aq is the foundation of most container cleanup scripts